{extend name="common/base" /}

{block name="title"}<title>编辑推广用户</title>{/block}

{block name="main"}
<div class="layui-fluid table">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-body">
                    <div class="layui-form" lwid100="" iwid300="" lay-filter="form">
                        <input name='id' type="hidden" value=''>
                        <div class="layui-form-item" style="">
                            <label class="layui-form-label">用户手机号</label>
                            <div class="layui-input-inline">
                                <input class="layui-input" placeholder="用户手机号" type="text" lay-verify="required" name="mobile">
                            </div>
                            <div class="layui-form-mid layui-word-aux"></div>
                        </div>
                        <div class="layui-form-item" style="">
                            <label class="layui-form-label">用户姓名</label>
                            <div class="layui-input-inline">
                                <input class="layui-input" placeholder="用户姓名" type="text" lay-verify="required" name="realname">
                            </div>
                            <div class="layui-form-mid layui-word-aux"></div>
                        </div>
                        <div class="layui-form-item" style="">
                            <label class="layui-form-label">绑定用户ID</label>
                            <div class="layui-input-inline">
                                <input class="layui-input" placeholder="绑定用户ID" type="text" lay-verify="required" name="member_id">
                            </div>
                            <div class="layui-form-mid layui-word-aux"></div>
                        </div>
                        <div class="layui-form-item">
                            <div class="layui-input-block">
                                <button class="layui-btn" lay-submit="" lay-filter="save">保存</button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

{/block}


<script>
    {block name="layui_table"}

    var index = parent.layer.getFrameIndex(window.name);

    $('#close').on("click",function () {
        parent.layer.close(index);
    });

    var list_url,cols ='';
    {/block}
</script>
{block name="footer"}
<script>
    layui.use(['form', 'layer','upload'],
        function() {
            let form = layui.form,
                upload = layui.upload,
                $ = layui.jquery,
                layer = layui.layer;
            form.val("form", {
                'id':{$info['id']},
                "realname":"{$info['realname']}",
                "mobile":"{$info['mobile']}",
                "member_id":{$info['member_id']},
            });
            //监听提交
            form.on('submit(save)',function(data) {
                let load;
                //发异步，把数据提交给php
                $.ajax({
                    url:"/backmanage/Spread/edit",
                    data:data.field,
                    type:"Post",
                    traditional: true,
                    dataType:"json",
                    beforeSend:function () {
                        //加载动画
                        load = layer.load(0, {shade: false});
                    },
                    success:function(data){
                        layer.close(load);
                        if(!data.code){
                            layer.alert("操作成功", {icon: 6},function () {
                                // 可以对父窗口进行刷新
                                window.parent.location.reload();
                                // 获得frame索引
                                var index = parent.layer.getFrameIndex(window.name);
                                //关闭当前frame
                                parent.layer.close(index);
                            });
                        }else{
                            layer.msg('操作失败');
                        }
                    },
                    error:function(data){
                        layer.close(load);
                        layer.msg('操作失败');
                    }
                });
                return false;
            });
        });
</script>
{/block}
